﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PJBWebsite.UserControls
{
    public partial class TextSearchControl : System.Web.UI.UserControl
    {
        #region Page Events

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            cmdSearchGo.Click += cmdSearchGo_Click;
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            textsearchblock.Attributes.Add("onkeypress", "javascript:return WebForm_FireDefaultButton(event, '" + cmdSearchGo.ClientID + "')");
        }

        #endregion

        #region Events

        public event EventHandler Search;

        protected void OnSearch(EventArgs e)
        {
            if (this.Search != null)
                this.Search(this, e);
        }

        #endregion

        #region Property Implementations

        public string SearchText
        {
            get { return txtBox.Text; }
            set { txtBox.Text = value; }
        }

        public string ToolTip
        {
            get { return txtBox.ToolTip; }
            set { txtBox.ToolTip = value; }
        }

        #endregion

        #region Event Handlers

        private void cmdSearchGo_Click(object sender, EventArgs e)
        {
            this.OnSearch(new EventArgs());
        }

        #endregion

    }
}